home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Sources / ODText.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.3 KB  |  107 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            ODText.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef _ODTEXT_
  14. #include "ODText.h"
  15. #endif
  16.  
  17. #ifndef _EMBEDRUN_
  18. #include "EmbedRun.h"
  19. #endif
  20.  
  21. // ----- Framework Includes -----
  22.  
  23. #ifndef FWGRDEF_H
  24. #include <FWGrDef.h>
  25. #endif
  26.  
  27. //========================================================================================
  28. // CLASS COpenDocText
  29. //========================================================================================
  30.  
  31. //----------------------------------------------------------------------------------------
  32. // COpenDocText::COpenDocText
  33. //----------------------------------------------------------------------------------------
  34.  
  35. COpenDocText::COpenDocText()
  36. {
  37. }
  38.  
  39. //----------------------------------------------------------------------------------------
  40. // COpenDocText::~COpenDocText
  41. //----------------------------------------------------------------------------------------
  42.  
  43. COpenDocText::~COpenDocText()
  44. {
  45. }
  46.  
  47. //----------------------------------------------------------------------------------------
  48. // COpenDocText::COpenDocText
  49. //----------------------------------------------------------------------------------------
  50.  
  51. OSErr COpenDocText::InitOpenDocText(GrafPtr textPort,
  52.                                     TTextensionHandlers* handlers,
  53.                                     TSize sizeInfo)
  54. {
  55.     return CTextension::ITextension(textPort, handlers, sizeInfo);
  56. }
  57.  
  58. //----------------------------------------------------------------------------------------
  59. // COpenDocText::NotifyEmbeddedPartsOfPositionChange
  60. //----------------------------------------------------------------------------------------
  61.  
  62. void COpenDocText::NotifyEmbeddedPartsOfPositionChange(long firstFormatLine,
  63.                                                        long lastFormatLine)
  64. {
  65.     // ----- Notify embedded parts that their position may have changed
  66.  
  67.     long runLength;
  68.     CRunObject* run;
  69.     
  70.     long lineStart = fFormatter->GetLineStart(firstFormatLine);
  71.     CRunsRanges* runsRanges = this->GetRunsRanges();
  72.          
  73.     while (runsRanges->GetNextRun(lineStart, &run, &runLength) >= 0)
  74.     {
  75.         if (run->GetClassId() == kEmbeddedPartClassId)
  76.         {
  77.             FW_SPlatformPoint pt;
  78.             short hite;
  79.             long top, edge;
  80.             short ascent, descent, leading;
  81.             
  82.             short selectionWidth = ((CEmbeddedRun *) run)->GetSelectionWidth();
  83.             
  84.             run->GetHiteInfo(&ascent, &descent, &leading);
  85.             this->Char2Point(lineStart, &top, &edge, &hite);
  86.             pt.v = (short) top + hite - (ascent + descent + leading) + selectionWidth;
  87.             pt.h = (short) edge + selectionWidth;
  88.             
  89.             ((CEmbeddedRun *) run)->ChangePosition(pt);
  90.         }
  91.         lineStart += runLength;
  92.     }    
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // COpenDocText::COpenDocText
  97. //----------------------------------------------------------------------------------------
  98.  
  99. void COpenDocText::EndEdit(const TEditInfo* editInfo,
  100.                            long firstFormatLine, long lastFormatLine,
  101.                            TOffset* selOffset, Boolean updateKeyScript)
  102. {
  103.     this->NotifyEmbeddedPartsOfPositionChange(firstFormatLine, lastFormatLine);    
  104.     CTextension::EndEdit(editInfo, firstFormatLine, lastFormatLine,
  105.                          selOffset, updateKeyScript);
  106. }
  107.